﻿using CollegeReviewApp.Data;
using CollegeReviewApp.DataModels;
using CollegeReviewApp.Web.IDataAdapters.Adapters;
using CollegeReviewApp.Web.IDataAdapters.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace CollegeReviewApp.Web.Controllers
{
    public class CollegesController : ApiController
    {
        ICollegeReviewAdapter _adapter = new CollegeReviewAdapter();
        public IHttpActionResult GET()
        {
            //returns all colleges
            return Ok(_adapter.GetAllColleges());
        }
        public IHttpActionResult GET(int id)
        {
            //returns one college
            return Ok(_adapter.GetCollege(id));
        }
        public IHttpActionResult POST(College college)
        {
            //Create a college in db
            return Ok(_adapter.AddCollege(college));//returns the ID of POST
        }
        public IHttpActionResult PUT(College college)
        {
            //update a college
            return Ok(_adapter.UpdateCollege(college));
        }
        public IHttpActionResult DELETE(int id)
        {
            //Delete a college
            _adapter.DeleteCollege(id);
            return Ok();
        }
    }
}
